/*
 * @Description:
 * @Author: chenju
 * @Date: 2021-11-08 15:37:26
 * @LastEditors: qingyang
 * @LastEditTime: 2023-06-29 10:45:18
 */
import { get, post } from '@/utils/http'
import type { BasicPagingListParams, BasicPagingListResult } from '@/apis/basicModel'

import type {
  GetReleaseListParams,
  GetReleaseListResultModel,
  CreateReleaseParams,
  ReleaseParams,
  GetReleaseInfoResult,
  IParamsSaveSystem
} from './model/informationModel'
enum Api {
  // 信息发布列表
  GET_RELEASE_LIST = '/upms/systemNotify/releaseInfoPage',
  // 新增发布保存为草稿
  CREATE_RELEASE = '/upms/systemNotify/saveDraft',
  // 发布
  RELEASE = '/upms/systemNotify/release',
  // 信息详情
  GET_RELEASE_INFO = '/upms/systemNotify/detail',
  // 置顶
  TOP_RELEASE_INFO = '/upms/systemNotify/top',
  // 撤回
  WITHDRAW_RELEASE = '/upms/systemNotify/withdraw',
  // 删除
  DELETE_RELEASE = '/upms/systemNotify/delete',
  // 取消置顶
  CANCEL_RELEASE = '/upms/systemNotify/cancelTop',
  // 信息发布-发布/存为草稿
  SAVE_SYSTEM = '/upms/systemNotify/saveSystemNotify'
}

// 信息发布列表
export const getReleaseList = (
  params: GetReleaseListParams & BasicPagingListParams
): Promise<BasicPagingListResult<GetReleaseListResultModel>> => get(Api.GET_RELEASE_LIST, params)

// 新增发布
export const createRelease = (params: CreateReleaseParams): Promise<void> =>
  post(Api.CREATE_RELEASE, params)

// 新增发布
export const saveSystem = (params: IParamsSaveSystem): Promise<void> =>
  post(Api.SAVE_SYSTEM, params)

// 发布
export const release = (params: ReleaseParams): Promise<void> => post(Api.RELEASE, params)

// 信息详情
export const getReleaseInfoDetail = (id: number): Promise<GetReleaseInfoResult> =>
  get(Api.GET_RELEASE_INFO, { id })

// 置顶
export const topRelease = (id: number): Promise<void> => post(Api.TOP_RELEASE_INFO, { id })

// 撤回
export const withdrawRelease = (id: number): Promise<void> => post(Api.WITHDRAW_RELEASE, { id })

// 删除发布信息
export const deleteRelease = (id: number): Promise<void> => post(Api.DELETE_RELEASE, { id })

// 取消置顶
export const cancelRelease = (id: number): Promise<void> => post(Api.CANCEL_RELEASE, { id })
